import Main from '@/views/main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => { require(['@/views/error-page/404.vue'], resolve); }
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: resolve => { require(['@//views/error-page/403.vue'], resolve); }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: resolve => { require(['@/views/error-page/500.vue'], resolve); }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        { path: 'home', title: '首页', name: 'home_index', component: resolve => { require(['@/views/home/home.vue'], resolve); } }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/test1',
        icon: 'key',
        name: 'test1',
        title: '测试1',
        component: Main,
        children: [
            {path: 'test1_1', title: '测试1-1', name: 'test1_1', permission: true, component: resolve => { require(['@/views/test1/test1.vue'], resolve);}},
            {path: 'test1_2', title: '测试1-2', name: 'test1_2',  component: resolve => { require(['@/views/test1/test1_2.vue'], resolve);}}
        ]
    },
    {
        path: '/test2',
        icon: 'key',
        name: 'test2',
        title: '测试2',
        component: Main,
        children: [
            {path: 'test2_1', title: '测试2-1', name: 'test2_1', component: resolve => { require(['@/views/test2/test2.vue'], resolve);}},
            {path: 'test2_2', title: '测试2-2', name: 'test2_2', permission: true, component: resolve => { require(['@/views/test2/test2_2.vue'], resolve);}}
        ]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    otherRouter,
    ...appRouter,
    page500,
    page403,
    page404
];
